﻿using System;
using System.IO;
using System.Reflection;

namespace DssNewServiceLoader
{
	public class NewServiceLoader
	{
		public static int Main(string[] args)
		{
			Assembly dssNewService = Assembly.LoadFile(
				Path.Combine(
					Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), 
					"dssnewservice.exe"));
			if (dssNewService != null)
			{
				Type newService = dssNewService.GetType("Microsoft.Dss.Tools.DssNewService.Program",true);
				if (newService != null)
				{
					MethodInfo mainMethod = newService.GetMethod("Main", BindingFlags.NonPublic | BindingFlags.Static);
					if (mainMethod != null)
						return (int) mainMethod.Invoke(null, new object[]{args});
				}
			}
			return 1;
		}
	}
}